From: Philip Withnall Date: Tue, 28 May 2024 17:03:11 +0000 (+0100) Subject: messageTray: Add removeAction() method and allow references to actions X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~173^2^2~158 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=03e3d9f435b5e23ae4c43dc30846d18e02526ced;p=gnome-shell.git messageTray: Add removeAction() method and allow references to actions Internally in gnome-shell it may be useful to modify the actions available on a notification while it’s still visible, but without clearing them all and re-creating them. Allow that by returning the action object when adding it, and adding a `removeAction()` method which takes that object and removes it. Signed-off-by: Philip Withnall Part-of: --- diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 80240b1ee..7c6f2f5db 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -439,6 +439,16 @@ export class Notification extends GObject.Object { }); this._actions.push(action); this.emit('action-added', action); + return action; + } + + removeAction(action) { + const index = this._actions.indexOf(action); + if (index < 0) + throw new Error('Action was already removed previously'); + + this._actions.splice(index, 1); + this.emit('action-removed', action); } clearActions() {